#include <bits/stdc++.h>
using namespace std;
const int N=1e5+10;
struct car
{
    int pos,a;
    double vv;
};
car c[N];
int p[N];
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int t;
    int n,m,l;
    double v;
    scanf("%d",&t);
    while(t--)
    {
        int ans=0;
        memset(c,0,sizeof(c));
        memset(p,0,sizeof(p));
        scanf("%d%d%d",&n,&m,&l);
        cin>>v;
        for(int i=1;i<=n;i++)
        {
            scanf("%d",&c[i].pos);
            cin>>c[i].vv;
            scanf("%d",&c[i].a);
        }
        for(int i=1;i<=m;i++)
        {
            scanf("%d",&p[i]);
        }
        int maxn=0;
        for(int i=1;i<=m;i++)
            if(p[i]>maxn)
                maxn=p[i];
        p[m]=maxn;
        p[m]=min(p[m],l);
        double ll=(double)(p[m]);
        for(int i=1;i<=n;i++)
        {
            if(c[i].a>=0)
            {
                if(c[i].pos>p[m])
                    continue;
                double s=(v*v-c[i].vv*c[i].vv)*1.0/(2.0*c[i].a)+c[i].pos;
                if(s<ll)
                    ans++;
            }
        }
        if(ans==0)
            printf("%d %d\n",ans,m);
        else
            printf("%d %d\n",ans,m-1);
    }
    return 0;
}
